﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace WCSY.BLL
{
    public class fg_InitialBuDetManager
    {
        private readonly WCSY.DAL.fg_InitialBuDetService dal=new WCSY.DAL.fg_InitialBuDetService();
        public fg_InitialBuDetManager()
		{}
        #region  Method

        /// <summary>
        /// 得到最大ID
        /// </summary>
        public int GetMaxId()
        {
            return dal.GetMaxId();
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string sysno, int lineid)
        {
            return dal.Exists(sysno, lineid);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public string Add(WCSY.MODEL.fg_InitialBuDet MODEL)
        {
            return dal.Add(MODEL);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WCSY.MODEL.fg_InitialBuDet MODEL)
        {
            return dal.Update(MODEL);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(string sysno, int lineid)
        {

            return dal.Delete(sysno, lineid);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public string Delete(string sysno)
        {

            return dal.Delete(sysno);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WCSY.MODEL.fg_InitialBuDet GetMODEL(string sysno, int lineid)
        {

            return dal.GetMODEL(sysno, lineid);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<WCSY.MODEL.fg_InitialBuDet> GetMODELList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<WCSY.MODEL.fg_InitialBuDet> DataTableToList(DataTable dt)
        {
            List<WCSY.MODEL.fg_InitialBuDet> MODELList = new List<WCSY.MODEL.fg_InitialBuDet>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                WCSY.MODEL.fg_InitialBuDet MODEL;
                for (int n = 0; n < rowsCount; n++)
                {
                    MODEL = new WCSY.MODEL.fg_InitialBuDet();
                    if (dt.Rows[n]["sysno"] != null && dt.Rows[n]["sysno"].ToString() != "")
                    {
                        MODEL.sysno = dt.Rows[n]["sysno"].ToString();
                    }
                    if (dt.Rows[n]["lineid"] != null && dt.Rows[n]["lineid"].ToString() != "")
                    {
                        MODEL.lineid = int.Parse(dt.Rows[n]["lineid"].ToString());
                    }
                    if (dt.Rows[n]["deptno"] != null && dt.Rows[n]["deptno"].ToString() != "")
                    {
                        MODEL.deptno = dt.Rows[n]["deptno"].ToString();
                    }
                    if (dt.Rows[n]["deptname"] != null && dt.Rows[n]["deptname"].ToString() != "")
                    {
                        MODEL.deptname = dt.Rows[n]["deptname"].ToString();
                    }
                    if (dt.Rows[n]["costsno"] != null && dt.Rows[n]["costsno"].ToString() != "")
                    {
                        MODEL.costsno = dt.Rows[n]["costsno"].ToString();
                    }
                    if (dt.Rows[n]["costsname"] != null && dt.Rows[n]["costsname"].ToString() != "")
                    {
                        MODEL.costsname = dt.Rows[n]["costsname"].ToString();
                    }
                    if (dt.Rows[n]["bumoney"] != null && dt.Rows[n]["bumoney"].ToString() != "")
                    {
                        MODEL.bumoney = decimal.Parse(dt.Rows[n]["bumoney"].ToString());
                    }
                    MODELList.Add(MODEL);
                }
            }
            return MODELList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            return dal.GetRecordCount(strWhere);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  Method
    }
}
